package org.cvcsc.weproject.controller.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import org.cvcsc.weproject.domain.Student;

@Schema(description = "学生信息数据传输对象")
public class ResponseDtoStudent {
    @Schema(description = "学生ID", example = "1")
    private Long id;

    @Schema(description = "学生姓名", example = "张三")
    private String name;

    @Schema(description = "学生学号", example = "2023001")
    private String number;

    @Schema(description = "班级ID", example = "101")
    private Long clazzId;

    // 构造方法、Getter 和 Setter
    public ResponseDtoStudent() {
    }

    public ResponseDtoStudent(Long id, String name, String studentNumber, Long clazzId) {
        this.id = id;
        this.name = name;
        this.number = studentNumber;
        this.clazzId = clazzId;
    }

    // Getter 和 Setter 方法
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public Long getClazzId() {
        return clazzId;
    }

    public void setClazzId(Long clazzId) {
        this.clazzId = clazzId;
    }

    // 静态工厂方法：将 Student 实体转换为 StudentDTO
    public static ResponseDtoStudent fromEntity(Student student) {
        return new ResponseDtoStudent(
                student.getId(),
                student.getStudentNameAndNumber().getName(),
                student.getStudentNameAndNumber().getNumber(),
                student.getClazz().getId());
    }
}
